package com.smarth.zhizulian.utils.listhelper.impl.model;

import com.smarth.zhizulian.utils.listhelper.inter.IDataModel;
import com.smarth.zhizulian.utils.listhelper.inter.ResponseSender;

import java.util.List;

/**
 * Created by 18865 on 2018/1/16.
 */

public abstract class ListDataModel<T extends List> implements IDataModel<T> {
    public int mPage = 1;
    public int mMaxPage = 1;

    @Override
    public void refresh(ResponseSender<T> responseSender) {
        fetch(responseSender, 1);
    }

    @Override
    public void loadMore(ResponseSender<T> responseSender) {
        fetch(responseSender, mPage + 1);
    }

    @Override
    public boolean hasMore() {
        return (mPage + 1) < mMaxPage;
    }

    public abstract void fetch(final ResponseSender<T> responseSender, int page);

    public int getmPage() {
        return mPage;
    }

    public void setmPage(int mPage) {
        this.mPage = mPage;
    }

    public int getmMaxPage() {
        return mMaxPage;
    }

    public void setmMaxPage(int mMaxPage) {
        this.mMaxPage = mMaxPage;
    }
}
